package  
{
	import flash.display.MovieClip;
	/**
	 * ...
	 * @author Seven Gae
	 */
	public class Particles extends MovieClip
	{
		public static var list: Array = new Array;
		
		private var velocityX:Number;
		private var velocityY:Number;
		
		public function Particles() 
		{
			velocityX = Math.random() * 10 - 5;
			velocityY = Math.random() * 10 - 5;
			this.rotation = Math.random() * 360;
			scaleX = scaleY = Math.random() + 0.5;
			alpha = Math.random() + 0.5;
			
			scaleX = scaleY = 0.5;
		}
		
		public static function createParticles(count:int, x:Number, y:Number):void
		{
			for (var i: int = 0; i < count; i++)
			{
				var particle = new Particles();
				particle.x = x;
				particle.y = y;
				Main.Self.screen.addChild(particle);
				list.push(particle);
			}
		}
		
		public static function update()
		{
			for (var i: int = 0; i < list.length; i++)
			{
				list[i].updateParticle(i);
			}
			
		}
		
		private function updateParticle(i:int):void
		{
			this.x += velocityX;
			this.y += velocityY;
			velocityY += 0.4;
			
			this.alpha -= 0.05;
			
			if (this.alpha < 0)
			{
				Main.Self.screen.removeChild(this);
				list.splice(i, 1);
				
			}
		}
	}

}